package view
{
	import flash.display.Sprite;
	
	public class FieldView extends Sprite
	{
		private var _squaresX:int = 1;
		private var _squaresY:int = 1;
		
		public function FieldView()
		{
		}
		
		public function get squaresX():int
		{
			return _squaresX;
		}

		public function set squaresX(value:int):void
		{
			if (value < 1)
				_squaresX = 1;
			else
				_squaresX = value;
			updateGrid();
		}

		public function get squaresY():int
		{
			return _squaresY;
		}

		public function set squaresY(value:int):void
		{
			if (value < 1)
				_squaresY = 1;
			else
				_squaresY = value;
			updateGrid();
		}

		private function updateGrid():void
		{
			var w:int = 100;
			var h:int = 100;
			
			graphics.lineStyle(0, 0xf0f0f0);
			var stepX:Number = w / _squaresX;
			var stepY:Number = h / _squaresY;
			
			for (var x:int = 1; x < _squaresX; x++)
			{
				graphics.moveTo(stepX*x, 0);
				graphics.lineTo(stepX*x, h);
			}
			for (var y:int = 1; y < _squaresY; y++)
			{
				graphics.moveTo(0, stepY*y);
				graphics.lineTo(w, stepY*y);
			}
		}
	}
}